<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let obj = {
        name: "pp",
        age: 12,
      };

      function forEachKey(callback) {
        for (let i = 0; i < localStorage.length; i++) {
          callback(localStorage.key(i));
        }
      }

      sessionStorage.setItem("key", "value");
      // 最终是存储在 sessionStorage 中 所以可以直接操作对象
      sessionStorage.name = "cap";

      sessionStorage["age"] = 12;

      console.log(sessionStorage);
    </script>
  </body>
</html>
